const path = require('path');
const webpack = require('webpack');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var ExtractTextPlugin = require('extract-text-webpack-plugin');

const config = {
	context: __dirname,
	node: { console: true,
		global: true,
		process: true,
		Buffer: true,
		__filename: true,
		__dirname: true,
		setImmediate: true
	},
  module: {
    rules: [
			{
				test: /\.css$/,
				loader: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use:['css-loader']
				})
			},
			{
				test : /\.less$/,
				loader: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use:['css-loader','less-loader']
				})
			},
			{
				test: /\.(js)$|\.(jsx)$/,
				use: 'babel-loader',
				exclude: /node_modules/
			}
    ]
  },
	stats: {
		colors: true
	},
	plugins: [
		new ExtractTextPlugin({
			filename: "[name].css",
			disable: false,
			allChunks: true
		}),
		new webpack.optimize.UglifyJsPlugin({
			sourceMap: false
		})
  ],
	externals: {
	}
};

module.exports = config;
